/*
  Copyright © 2011  Vinícius dos Santos Oliveira

  This file is part of Vinipsmaker's HTTP tools.

  Vinipsmaker's HTTP tools is free software: you can redistribute it and/or
  modify it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or (at your
  option) any later version.

  This program is distributed in the hope that it will be useful, but WITHOUT
  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
  details.

  You should have received a copy of the GNU General Public License along with
  this program.  If not, see <http://www.gnu.org/licenses/>.
  */

#ifndef REQUESTWINDOW_H
#define REQUESTWINDOW_H

#include <QMainWindow>

namespace Ui {
    class RequestWindow;
}

class QButtonGroup;
class QNetworkAccessManager;
class QNetworkReply;
class QListWidgetItem;
class IODeviceManager;
class QTemporaryFile;

class RequestWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit RequestWindow(QWidget *parent = 0);
    ~RequestWindow();

private slots:
    void on_addHeaderButton_clicked();
    void on_editHeaderButton_clicked();
    void on_removeHeaderButton_clicked();

    void on_textEntityBodyButton_toggled(bool checked);
    void on_fileEntityBodyButton_toggled(bool checked);
    void on_noneEntityBodyButton_toggled(bool checked);

    void on_entityBodyFileChooserButton_clicked();
    void on_addContentLengthButton_clicked();

    void on_urlCodecButton_clicked();

    void on_saveRequestButton_clicked();
    void on_loadRequestButton_clicked();

    void on_requestButton_clicked();
    void onNetworkReplyFinished();

    void on_showAsTextButton_clicked();
    void on_saveEntityBodyResponseButton_clicked();

private:
    QListWidgetItem *headerItem(const QString &headerKey);

    Ui::RequestWindow *ui;
    QButtonGroup *entityBodyMenuButtonGroup;
    QString hostUrl;
    QNetworkAccessManager *networkAccessManager;
    IODeviceManager *requestEntityBody;
    QNetworkReply *reply;
    QTemporaryFile *responseEntityBody;
};

#endif // REQUESTWINDOW_H
